package org.androidmangher.controller;

import org.androidmangher.bean.User;
import org.androidmangher.bean.video;
import org.androidmangher.service.HomeListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/home")
public class HomeListController {

    @Autowired
    private HomeListService homeListService;

    @GetMapping("/videoList")
    public Map getUserList(){

        List<video> VideoList = homeListService.getVideoList();
        HashMap<String, Object> message = new HashMap<>();

        if (VideoList==null){
            message.put("code","00");
            message.put("message","erro");
            message.put("userinfo",null);

        }else {
            message.put("code","01");
            message.put("message","sucess");
            message.put("userinfo",VideoList);

        }
        return message;
    }


}
